package com.study.spmongodb.wwj.thread.char11;

/**
 * @author MI
 * @version 1.0
 * @date 2020/12/6 17:31
 */
public class ThreadException {

    private final static int A = 10;
    private final static int B = 0;

    public static void main(String[] args) {
        final Thread thread = new Thread(() -> {
            try {
                Thread.sleep(5_000L);
                int result = A / B;
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        //捕获线程运行期间的异常
        thread.setUncaughtExceptionHandler((t, e) -> {
            System.out.println(e);
            System.out.println(t);
        });
        thread.start();
    }
}
